package homewoek12月12号.homework2.h3;

import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.util.ArrayList;
import java.util.List;

public class demo {
    public static void main(String[] args) throws Exception {
        SAXReader reader = new SAXReader();
        Document read = reader.read("D:\\ldea dashuju\\day.12.11\\src\\czxy\\homework\\h3\\student.xml");
        Element root = read.getRootElement();
        List<Element> student = root.elements();
        ArrayList<Student> slist = new ArrayList<>();
        for (Element element : student) {
           slist.add(new Student(element.attributeValue("stuNo"),element.elementText("name"),
                   Integer.parseInt(element.elementText("age")),element.elementText("sex"),Integer.parseInt(element.elementText("score"))));
        }
        System.out.println(slist);
    }
}
